#pragma once

#include "Common.h"

const u32 NR_OF_MOUSE_BUTTONS = 8;

///
const u32 BUTTON_1      = 0x00;
const u32 BUTTON_2      = 0x01;
const u32 BUTTON_3      = 0x02;
const u32 BUTTON_4      = 0x03;
const u32 BUTTON_5      = 0x04;
const u32 BUTTON_6      = 0x05;
const u32 BUTTON_7      = 0x06;
const u32 BUTTON_8      = 0x07;
const u32 BUTTON_LEFT   = 0x00;
const u32 BUTTON_RIGHT  = 0x01;
const u32 BUTTON_MIDDLE = 0x02;

/// Mouse button structure
struct MouseButtonState
{
	MouseButtonState()
	{
		mButtonDown = FALSE;
		mButtonPressed = FALSE;
		mButtonReleased = FALSE;
	}

	bool mButtonDown;
	bool mButtonPressed;
	bool mButtonReleased;
};

///
class Mouse
{
public:
	CONSTRUCTOR Mouse();
	DESTRUCTOR ~Mouse();

	bool Setup(HWND Window, bool Exclusive = FALSE);
	VOID Shutdown();

	VOID Update();

	bool ButtonDown(u32 Button) const;
	bool ButtonPressed(u32 Button) const;
	bool ButtonReleased(u32 Button) const;

	bool AnyButtonDown() const;
	bool AnyButtonPressed() const;
	bool AnyButtonReleased() const;

	s32 GetDX() const;
	s32 GetDY() const;
	s32 GetDZ() const;

protected:
	bool ValidButton(u32 Button) const;

	LPDIRECTINPUT8 DirectInput;
	LPDIRECTINPUTDEVICE8 MouseDevice;

	MouseButtonState AnyButtonState;
	MouseButtonState ButtonState[NR_OF_MOUSE_BUTTONS];

	s32 DX;
	s32 DY;
	s32 DZ;
};